<?
function djtree2($tjuser,$ceng,&$arrnum){	
        global $db,$db_prefix,$arrnum; 	/*
		$tjnumstr=implode(",",$arrnum); 
		echo "<script>alert('$tjnumstr');</script>";*/
		if($ceng==0)
		{	
			$sqlchktjnumstr="select * from {$db_prefix}users where username='".trim($tjuser)."' and state=1";
			$rstjs=$db->get_one($sqlchktjnumstr);
			$tjnum1=$rstjs["tjnum"];
			if($tjnum1>0){
				$arrnum[$ceng]=$tjnum1; //节点自己的	
				$ceng1=$ceng+1;
				djtree2($tjuser,$ceng1,$arrnum);
			}
			else
				return true;

		}
		else
		{	
			$sqltjs="select * from {$db_prefix}users where tjuser='".$tjuser."' and state=1";
			$rstjs=$db->get_all($sqltjs);		
			foreach ($rstjs as $key => $rstj) 
			{
				$tjnum1=$rstj["tjnum"];
				$username=$rstj["username"];				
				if($tjnum1>0){
					$arrnum[$ceng]=$arrnum[$ceng]+$tjnum1; //节点自己的
					$arrnumceng=$arrnum[$ceng];
					djtree2($rstj["username"],$ceng+1,$arrnum); //节点下级的
				}
			}	
			return true;
		}
}

?>
